package com.lwd.boot.study.auto;

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: 刘东（挂兰）
 * @Date: 2024/1/1 08:37:16
 * @Description:
 */
@EnableConfigurationProperties(CustomerProperties.class)
@Configuration
// 类里要存在CustomerProperties这个类才加载
@ConditionalOnClass(CustomerProperties.class)
@ComponentScan("com.lwd.boot.study.auto")
//  需要有这个前缀 CustomerConstant.CUSTOMER_PREFIX
//  并且 配置文件需要有这个值CustomerConstant.ENABLED (这个值是什么不重要 但是一定要有值 如果需要匹配固定的值 加这个属性 havingValue)
@ConditionalOnProperty(prefix = CustomerConstant.CUSTOMER_PREFIX,
		value = CustomerConstant.ENABLED)
public class CustomerAutoConfiguration {

	@Bean
	public AutoConfigurationService getBean() {
		AutoConfigurationServiceImpl autoConfigurationService = new AutoConfigurationServiceImpl();
		return autoConfigurationService;
	}
}
